<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>数据库还原</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="Author" content="larry" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/static/admin/common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/base.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/common/css/animate.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="larry-container larryms-admin">
        <div class="layui-row layui-col-space20">
            <div class="layui-col-xs12 animated fadeInRightBig">
                <section class="larry-panel">
                    <div class="larryms-page-header">
                        <span class="tit">数据库还原</span>
                    </div>
                    <div class="larryms-page-body">

                        <form method="post">
                            <table class="layui-table">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>备份名称</th>
                                    <th>备份时间</th>
                                    <th>备份大小</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {notempty name="dataList"}
                                    {volist name="dataList" id="vo"}
                                        <tr>
                                            <td>{$i}</td>
                                            <td>{$vo.name}</td>
                                            <td>{$vo.time}</td>
                                            <td>{$vo.size}</td>
                                            <td>
                                                    <div class="layui-btn-group">
                                                        <a class="layui-btn layui-btn-primary layui-btn-sm"  href="javascript:void(0);" onclick="restoreTable('{$vo.name}')" data-value="{$vo.name}"><i class="layui-icon">&#xe609;</i></a>
                                                        <a class="layui-btn layui-btn-primary layui-btn-sm" href="{:url('data/download',['table'=>$vo.name])}" id="table_name" data-value="{$vo.name}"><i class="layui-icon">&#xe601;</i></a>
                                                        <a class="layui-btn layui-btn-primary layui-btn-sm" href="javascript:void(0);" onclick="deleteTable(this, '{$vo.name}')"><i class="layui-icon"></i></a>
                                                    </div>
                                            </td>
                                        </tr>
                                    {/volist}
                                {else /}
                                <td colspan="7" style="text-align: center"> 暂未发现数据库表! </td>
                                {/notempty}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
<!-- 加载js文件-->
<script type="text/javascript" src="/static/admin/common/layui/layui.js"></script>
<script>
    var $,layer;
    layui.use(['jquery', 'layer'], function(){
        $ = layui.$;    //重点处
        layer = layui.layer;
    });
    //删除数据库
    function deleteTable(obj,tableName){
        if(obj && tableName){
            $.ajax({
                type:"POST",
                url:"{:url('admin/Data/delete')}",
                dataType:"JSON",
                data:{'id':tableName},
                success:function(data){
                    // console.log(data.code);
                    if(data.code == '1'){
                        layer.msg(data.msg, {icon: 6});
                        $(obj).parents('tr').remove();
                        //console.log(data.code);
                    }else if(data.code == '-1'){
                        layer.msg(data.msg, {icon: 5});
                    }
                }
            });
        }
    }
    //还原数据库
    function restoreTable(tableName){
        if(tableName){
            $.ajax({
                type:"POST",
                url:"{:url('admin/data/restore')}",
                dataType:"JSON",
                data:{'id':tableName},
                success:function(data){
                    // console.log(data.code);
                    if(data.code == '1'){
                        layer.msg(data.msg, {icon: 6});
                        //console.log(data.code);
                    }else if(data.code == '-1'){
                        layer.msg(data.msg, {icon: 5});
                    }
                }
            });
        }
    }
</script>
</body>
</html>